stage.set_background("city")
sprite = codesters.Sprite("bike")
sprite.set_size(0.5)
sprite.go_to(-200, 0)
stage.set_gravity(10)
stage.disable_all_walls()
def space_bar():
sprite.jump(5)
# add other actions...
stage.event_key("space", space_bar)
def interval():
sprite.turn_left(15)
# add any other actions...
stage.event_interval(interval, 2)
t = codesters.Teacher()
try:
left = t.find_function('turn_left')
tval1 = left[0][0]
except:
tval1 = "DNE"
try:
params = t.find_text("randint")
tval2 = t.get_indent_at_line(params[0][0])
tval3 = params[0][1]
except:
tval2 = "DNE"
tval3 = "DNE"
# print tval2, tval3
t1 = TestObjective()
t1.add_success(tval1 == "DNE" or tval1 == None, "Great job!")
t1.add_failure(tval1 != "DNE" and tval1 != None, "Did you delete the Turn Left command in the interval?")
t2 = TestObjective()
t2.add_success(tval2 == 4 and "my_var" in tval3, "Great job!")
t2.add_failure(tval2 != 4, "Is your random number indented four spaces inside the interval?")
t2.add_failure(tval3 == "DNE" or tval3 == None, "Did you add a random number?")
# ds1 = codesters.Display(tval2)
tester = TestManager()
tester.add_test_list([t1, t2])
tester.run_tests()
tester.display_first_feedback()
-
Run Code
-
Activity Submitted!
Submit Work
-
Next Activity
-
Stop Running Code
-
Show Chart
-
Show Console
-
Reset Code Editor
-
Codesters How To (opens in a new tab)